<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
  <head>
    <title>app/models/survey.rb</title>
    <link href="screen.css" media="all" rel="stylesheet" type="text/css" />
    <link href="print.css" media="print" rel="stylesheet" type="text/css" />
    
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
    <script type="text/javascript" src="rcov.js"></script>
  </head>
  <body>
    <h1>Survey0 3 C0 Coverage Information - RCov</h1>
    <h2>app/models/survey.rb</h2>

    

    <div class="report_table_wrapper">
      <table class='report' id='report_table'>
        <thead>
          <tr>
            <th class="left_align">Name</th>
            <th class="right_align">Total Lines</th>
            <th class="right_align">Lines of Code</th>
            <th class="left_align">Total Coverage</th>
            <th class="left_align">Code Coverage</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td class="left_align"><a href="app-models-survey_rb.html">app/models/survey.rb</a></td>
            <td class='right_align'><tt>111</tt></td>
            <td class='right_align'><tt>88</tt></td>
            <td class="left_align"><div class="percent_graph_legend"><tt class=''>50.45%</tt></div>
          <div class="percent_graph">
            <div class="covered" style="width:50px"></div>
            <div class="uncovered" style="width:50px"></div>
          </div></td>
            <td class="left_align"><div class="percent_graph_legend"><tt class=''>45.45%</tt></div>
          <div class="percent_graph">
            <div class="covered" style="width:45px"></div>
            <div class="uncovered" style="width:55px"></div>
          </div></td>
          </tr>
        </tbody>
      </table>
    </div>
    
    <h3>Key</h3>
    
    <div class="key"><pre><span class='marked'>Code reported as executed by Ruby looks like this...</span><span class='marked1'>and this: this line is also marked as covered.</span><span class='inferred'>Lines considered as run by rcov, but not reported by Ruby, look like this,</span><span class='inferred1'>and this: these lines were inferred by rcov (using simple heuristics).</span><span class='uncovered'>Finally, here's a line marked as not executed.</span></pre></div>

    <h3>Coverage Details</h3>

    <table class="details">
      <tbody>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line1">1</a> </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line2">2</a> class Survey &lt; ActiveRecord::Base</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line3">3</a>   belongs_to :survey_type ,:class_name =&gt; 'SurveyType', :foreign_key =&gt; &quot;test_type_id&quot; </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line4">4</a>   belongs_to :user</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line5">5</a>   has_many :parts, :dependent =&gt; :destroy</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line6">6</a>   has_many :dimens, :dependent =&gt; :destroy</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line7">7</a>   has_many :questions, :order =&gt; :position, :dependent =&gt; :destroy</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line8">8</a>   has_many :trend_scales, :dependent =&gt; :destroy</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line9">9</a>   has_many :choices, :dependent =&gt; :destroy ,:foreign_key =&gt; &quot;test_id&quot; </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line10">10</a>   has_many :results, :dependent =&gt; :destroy</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line11">11</a>   has_many :norms, :dependent =&gt; :destroy</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line12">12</a>   has_many :images, :dependent =&gt; :destroy</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line13">13</a>   has_many :reports, :dependent =&gt; :destroy ,:foreign_key =&gt; &quot;test_id&quot; </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line14">14</a>   has_many :original_results</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line15">15</a>   has_many :pre_original_results</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line16">16</a>   has_one :survey_count_method, :dependent =&gt; :destroy</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line17">17</a>   has_one :norm_info, :dependent =&gt; :destroy</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line18">18</a>   has_and_belongs_to_many :users, :join_table =&gt; &quot;users_surveys&quot;</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line19">19</a>   has_many :orgs</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line20">20</a>   has_many :survey_records</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line21">21</a>   has_many :pre_survey_records</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line22">22</a>   </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line23">23</a>   validates_presence_of :name, :description</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line24">24</a>   #validates_presence_of :title ,:message =&gt;&quot;测试标题不能为空&quot;</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line25">25</a>   </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line26">26</a>   def parts_size</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line27">27</a>     Question.count(:conditions =&gt; [&quot;test_id = ? and marker = ?&quot;, self.id, QUESTION_MARKER_PART])</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line28">28</a>   end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line29">29</a> </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line30">30</a>   def self.prof_surveys</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line31">31</a>     Survey.find_all_by_professional(true)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line32">32</a>   end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line33">33</a> </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line34">34</a>   def self.prof_online_surveys</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line35">35</a>     Survey.find_all_by_professional_and_status_and_deleted(true, TEST_STATUS_FINISHED, false)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line36">36</a>   end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line37">37</a> </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line38">38</a>   def question_num</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line39">39</a>     if self.has_part == 1</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line40">40</a>       question_num = 0</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line41">41</a>       self.parts.each do |p|</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line42">42</a>         question_num += p.questions.size</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line43">43</a>       end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line44">44</a>       question_num</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line45">45</a>     else</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line46">46</a>       self.questions.size</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line47">47</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line48">48</a>   end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line49">49</a> </pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line50">50</a>   #对有分量表的测试进行分页</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line51">51</a>   def paging</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line52">52</a>     count = 0</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line53">53</a>     total = 0</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line54">54</a>     pages = []</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line55">55</a>     page = []</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line56">56</a>     page_size = self.page_size || QUESTION_PAGE_SIZE</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line57">57</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line58">58</a>     self.parts.each do |part|</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line59">59</a>       page.push({:item =&gt; part, :type =&gt; 'part'})</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line60">60</a>       </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line61">61</a>       part.questions.each do |question|</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line62">62</a>         page.push({:item =&gt; question, :type =&gt; 'question'})</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line63">63</a>         count += 1</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line64">64</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line65">65</a>         </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line66">66</a>         if count == page_size or total == self.question_num-1</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line67">67</a>           pages.push(page)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line68">68</a>           count = 0</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line69">69</a>           page = []</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line70">70</a>         end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line71">71</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line72">72</a>         total += 1</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line73">73</a>       end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line74">74</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line75">75</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line76">76</a>     return pages</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line77">77</a>   end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line78">78</a> </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line79">79</a>   def paging_no_part</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line80">80</a>     page_size = self.page_size || QUESTION_PAGE_SIZE</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line81">81</a>     page_num = (self.question_num%page_size == 0 and self.question_num-page_size &gt;= 0) ? self.question_num/page_size : self.question_num/page_size + 1</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line82">82</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line83">83</a>     pages = []</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line84">84</a>     (0...page_num).each do |i|</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line85">85</a>       pages[i] = self.questions[page_size*i..(page_size*i+page_size-1)]</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line86">86</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line87">87</a>     survey = {}</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line88">88</a>     survey[:pages] = pages</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line89">89</a>     return survey</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line90">90</a>   end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line91">91</a>   </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line92">92</a>   def self.t_surveys(per_page, page)</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line93">93</a>     sql = &quot;select * from surveys where &quot; +</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line94">94</a>           &quot;deleted is null and  t_type = '#{TEST_TYPE_TREND}' order by created_at desc &quot;</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line95">95</a>     Survey.paginate_by_sql(sql,{:per_page =&gt; per_page, :page=&gt;page})</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line96">96</a>   end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line97">97</a> </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line98">98</a>   def self.small_surveys_count</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line99">99</a>     self.count(:conditions =&gt; [&quot; t_type = 'small' and deleted is null&quot;])</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line100">100</a>   end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line101">101</a> </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line102">102</a>   def type_is_count</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line103">103</a>     self.t_type == '计分测试'</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line104">104</a>   end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line105">105</a> </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line106">106</a>   def type_is_trend</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line107">107</a>     self.t_type == '倾向测试'</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line108">108</a>   end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line109">109</a> end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line110">110</a> </pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line111">111</a> </pre></td>
          </tr>
        
      </tbody>
    </table>

    <p>Generated on Wed Mar 17 14:12:44 +0800 2010 with <a href="http://github.com/relevance/rcov">rcov 0.9.8</a></p>

  </body>
</html>
